import { h, provide, inject } from '../../lib/min-vue.esm.js'
const provider = {
  name: 'Provider',
  render() {
    return h('div', {}, [h('p', {}, 'provider'), h(providerTwo)])
  },
  setup() {
    provide('foo', 'fooVal')
  }
}
const providerTwo = {
  name: 'providerTwo',
  setup() {
    provide('foo', 'footwo')
    const foo = inject('foo')
    const foo2 = inject('default', 'foo2default')
    const foo3 = inject('default', () => {
      return 'foo3defaultFn'
    })
    return {
      foo,
      foo2,
      foo3
    }
  },
  render() {
    return h('div', {}, [
      h('p', {}, `providertwo:${this.foo}/${this.foo2}/${this.foo3}`),
      h(Consume)
    ])
  }
}

const Consume = {
  name: 'Consume',
  setup() {
    const foo = inject('foo')
    return {
      foo
    }
  },
  render() {
    return h('div', {}, `consume:${this.foo}`)
  }
}
export const App = {
  name: 'App',
  render() {
    return h('div', {}, [h('p', {}, 'App'), h(provider)])
    // return createTextVNode('你好呀')
  },

  setup() {
    return {}
  }
}
